<template>
  <div class="prepayment-management">
    <!-- 标题和功能说明 -->
    <div style="margin-bottom: 15px;">
      <h3>预存款管理</h3>
    </div>

    <!-- 标签页 -->
    <el-tabs v-model="activeTab" type="card" class="tabs">
      <el-tab-pane label="预存款管理" name="management">
        <!-- 操作栏：按钮 + 搜索 -->
        <div class="operation-bar">
          <el-button type="primary">预存款导入</el-button>
          <el-button type="success" style="margin-left: 10px;">预存款充值</el-button>
          <div class="search-group" style="margin-left: auto;">
            <el-input placeholder="小区/房号/手机号" style="width: 240px;" />
            <el-button type="primary" icon="el-icon-search"></el-button>
            <el-button type="primary" icon="el-icon-filter"></el-button>
          </div>
        </div>

        <!-- 预存款管理表格 -->
        <el-table :data="tableData" border style="width: 100%; margin-bottom: 20px;">
          <el-table-column prop="community" label="小区" />
          <el-table-column prop="ownerName" label="住户姓名" />
          <el-table-column prop="phone" label="手机号" width="150" />
          <el-table-column prop="type" label="类型" />
          <el-table-column prop="balance" label="预存款余额" />
          <el-table-column label="操作" width="220">
            <template slot-scope="scope">
              <el-button type="text" size="small">查看</el-button>
              <el-button type="success" size="small" plain>充值</el-button>
              <el-button type="danger" size="small" plain>删除</el-button>
            </template>
          </el-table-column>
        </el-table>

        <!-- 分页 -->
        <div class="pagination-wrap">
          <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
            :current-page="currentPage" :page-sizes="[10, 20, 30, 40]" :page-size="10"
            layout="prev, pager, next, ->, jumper, ->, sizes, total" :total="90" />
        </div>
      </el-tab-pane>
      <el-tab-pane label="预存款明细" name="detail" />
    </el-tabs>
  </div>
</template>

<script>
export default {
  name: 'PrepaymentManagement',
  data() {
    return {
      activeTab: 'management',
      currentPage: 1,
      tableData: [
        {
          community: '中山国际',
          ownerName: '张飒',
          phone: '18988985589',
          type: '物业费',
          balance: 350
        },
        {
          community: '中山国际',
          ownerName: '张飒',
          phone: '18988985589',
          type: '水费',
          balance: 20
        },
        {
          community: '中山国际',
          ownerName: '张飒',
          phone: '18988985589',
          type: '电费',
          balance: 20
        },
        {
          community: '中山国际',
          ownerName: '张飒',
          phone: '18988985589',
          type: '停车费',
          balance: 350
        },
        {
          community: '中山国际',
          ownerName: '张飒',
          phone: '18988985589',
          type: '垃圾处理费',
          balance: 50
        }
      ]
    }
  },
  methods: {
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`);
    },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
      this.currentPage = val;
    }
  }
}
</script>

<style scoped>
.prepayment-management {
  padding: 20px;
}

.desc {
  font-size: 14px;
  color: #606266;
  margin-bottom: 15px;
}

.tabs {
  margin-bottom: 15px;
}

.operation-bar {
  display: flex;
  align-items: center;
  margin-bottom: 15px;
}

.search-group {
  display: flex;
  align-items: center;
}

.search-group .el-input {
  margin-right: 8px;
}

.pagination-wrap {
  display: flex;
  justify-content: flex-end;
}
</style>